package com.bq.gametrade.http;

import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.widget.Toast;

import com.bq.gametrade.bean.AddressBook;
import com.bq.gametrade.bean.AliPay;
import com.bq.gametrade.bean.Announcement;
import com.bq.gametrade.bean.BankCardList;
import com.bq.gametrade.bean.BindGameAccount;
import com.bq.gametrade.bean.CancelledRecorded;
import com.bq.gametrade.bean.FriendsList;
import com.bq.gametrade.bean.FriendsListDetails;
import com.bq.gametrade.bean.GamesAccountDetails;
import com.bq.gametrade.bean.GamesList;
import com.bq.gametrade.bean.HomeTradingBean;
import com.bq.gametrade.bean.Interconnected;
import com.bq.gametrade.bean.RechargeMoney;
import com.bq.gametrade.bean.RechargeMoneyDetails;
import com.bq.gametrade.bean.RedEnvelopeList;
import com.bq.gametrade.bean.RedEnvelopeRecords;
import com.bq.gametrade.bean.ResponseBean;
import com.bq.gametrade.bean.TradingRecordsDetails;
import com.bq.gametrade.bean.TransferBill;
import com.bq.gametrade.bean.TransferContacts;
import com.bq.gametrade.bean.UpdateUserInfo;
import com.bq.gametrade.bean.UserInfo;
import com.bq.gametrade.bean.UserTradingRecord;
import com.bq.gametrade.bean.WeChatPay;
import com.bq.gametrade.bean.WithdrawalRecords;
import com.bq.gametrade.ui.dialog.LoadingProgressDialog;
import com.bq.gametrade.utils.ToastUtils;
import com.bq.httplibrary.AsyncHttp;
import com.bq.httplibrary.Listener;
import com.bq.httplibrary.NetroidError;
import com.bq.httplibrary.Request;
import com.bq.httplibrary.request.VRStringRequest;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * 功能：网络数据请求类
 * <p>
 * Created by user on 2016/4/26.
 */
public final class VRHttp {


    private static AsyncHttp asyncHttp = AsyncHttp.getInstance();

    /**
     * 获取用户信息
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void userToLogin(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    UserInfo userInfo = Parser.getUserInfo(response);
                    if (userInfo != null) {
                        vrHttpListener.onSuccess(userInfo, false);
                    } else {
                        vrHttpListener.onError(new String(Base64.decode(userInfo.message.getBytes(), 0, userInfo.message.length(), Base64.DEFAULT)));
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    UserInfo userInfo = Parser.getUserInfo(cahce);
                    if (userInfo.userinfo != null) {
                        vrHttpListener.onSuccess(userInfo.userinfo, true);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 获取用户信息
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void updateUserInfo(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    UpdateUserInfo userInfo = Parser.updateUserInfo(response);
                    if (userInfo != null) {
                        vrHttpListener.onSuccess(userInfo,false);

                    } else {
                       Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    UpdateUserInfo userInfo = Parser.updateUserInfo(cahce);
                    if (userInfo!= null) {
                        vrHttpListener.onSuccess(userInfo, true);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 首页获取交易列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getSellingList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    HomeTradingBean homeTradingBean = Parser.getSellingList(response);
                    if (homeTradingBean != null) {
                        vrHttpListener.onSuccess(homeTradingBean, false);
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    HomeTradingBean homeTradingBean = Parser.getSellingList(cahce);
                    if (homeTradingBean != null) {
                        vrHttpListener.onSuccess(homeTradingBean, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 交易记录详情
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getTradingRecordsDeatilsList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    TradingRecordsDetails details = Parser.getTradingRecordsDetailsList(response);
                    if (details != null) {
                        vrHttpListener.onSuccess(details, false);
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    TradingRecordsDetails details = Parser.getTradingRecordsDetailsList(cahce);
                    if (details != null) {
                        vrHttpListener.onSuccess(details, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 通用请求
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void sendRequest(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {

        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                Log.e("wu",response);
                if (!TextUtils.isEmpty(response)) {
                    ResponseBean responseBean = Parser.getResponseData(response);
                    vrHttpListener.onSuccess(responseBean, false);
                } else {
//                    ToastUtils.showToast(context, "加载数据出错");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    ResponseBean responseBean = Parser.getResponseData(cahce);
                    if (responseBean != null) {
                        vrHttpListener.onSuccess(responseBean, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
//                mPrgsDialog.cancel();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);


    }


    /**
     * 通用请求
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getGameAccountDetails(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {

        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    GamesAccountDetails gameAccountDetaills = Parser.getGameAccountDetaills(response);
                    vrHttpListener.onSuccess(gameAccountDetaills, false);
                } else {
                    ToastUtils.showToast(context, "加载数据出错");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    GamesAccountDetails gameAccountDetaills = Parser.getGameAccountDetaills(cahce);
                    if (gameAccountDetaills != null) {
                        vrHttpListener.onSuccess(gameAccountDetaills, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
//                mPrgsDialog.cancel();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);


    }



    /**
     * 微信支付
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void sendWeChatPay(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {

        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    WeChatPay weChatPay = Parser.sendWeChatPay(response);
                    vrHttpListener.onSuccess(weChatPay, false);
                } else {
                    ToastUtils.showToast(context, "加载数据出错");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    WeChatPay weChatPay = Parser.sendWeChatPay(cahce);
                    if (weChatPay != null) {
                        vrHttpListener.onSuccess(weChatPay, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
//                mPrgsDialog.cancel();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);


    }


    /**
     * 微信支付
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void sendAliPay(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {

        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    AliPay aliPay = Parser.sendAliPay(response);
                    vrHttpListener.onSuccess(aliPay, false);
                } else {
                    ToastUtils.showToast(context, "加载数据出错");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    AliPay aliPay = Parser.sendAliPay(cahce);
                    if (aliPay != null) {
                        vrHttpListener.onSuccess(aliPay, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
//                mPrgsDialog.cancel();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);


    }




    /**
     * 获取公告请求
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getAnnouncement(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {

        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    Announcement announcement = Parser.getAnnouncement(response);
                    vrHttpListener.onSuccess(announcement, false);
                } else {
                    ToastUtils.showToast(context, "加载数据出错");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    Announcement announcement = Parser.getAnnouncement(cahce);
                    if (announcement != null) {
                        vrHttpListener.onSuccess(announcement, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
//                mPrgsDialog.cancel();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);


    }


    /**
     * String类型
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getResponse(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {

            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    vrHttpListener.onSuccess(response, false);
                }
            }
            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                vrHttpListener.onError(error.toString());
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);

    }


    /**
     * 游戏名称列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getGamesNameList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    GamesList gamesList = Parser.getGamesNameList(response);
                    if (gamesList != null) {
                        vrHttpListener.onSuccess(gamesList, false);
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    GamesList gamesList = Parser.getGamesNameList(cahce);
                    if (gamesList != null) {
                        vrHttpListener.onSuccess(gamesList, true);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }



    /**
     * 获取转账联系人
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getTransferContactsList( final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    TransferContacts userFriend = Parser.getTransferContactsList(response);
                    if (userFriend != null) {
                        vrHttpListener.onSuccess(userFriend, true);
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    TransferContacts userFriend = Parser.getTransferContactsList(cahce);
                    if (userFriend != null) {
                        vrHttpListener.onSuccess(userFriend, true);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 获取通讯录联系人
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getAddressBookList( final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {

                    AddressBook userFriend = Parser.getAddressBookList(response);
                    if (userFriend != null) {
                        if(userFriend.status.equals("0")){
                            vrHttpListener.onSuccess(userFriend, true);

                        }
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    AddressBook userFriend = Parser.getAddressBookList(cahce);
                    if (userFriend != null) {
                        vrHttpListener.onSuccess(userFriend, true);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 获取通讯录联系人
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getMyFriendList( final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    FriendsList userFriend = Parser.getMyFriendList(response);
                    if (userFriend != null) {
                        if(userFriend.status.equals("0")){
                            vrHttpListener.onSuccess(userFriend, true);
                            ArrayList<FriendsListDetails> list = userFriend.friend_list;
                            if(list.size()>0){
                            }
                        }
//                        if (userInfoDetails != null) {
//                            vrHttpListener.onSuccess(userInfo, false);
//                        } else {
//                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
//                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    FriendsList userFriend = Parser.getMyFriendList(cahce);
                    if (userFriend != null) {
                        vrHttpListener.onSuccess(userFriend, true);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 游戏名称列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void getTransferBill(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    TransferBill transferBill = Parser.getTransferBillList(response);
                        if (transferBill != null) {
                            vrHttpListener.onSuccess(transferBill, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    TransferBill transferBill = Parser.getTransferBillList(cahce);
                    if (transferBill != null) {
                        vrHttpListener.onSuccess(transferBill, false);

                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }



    /**
     * 游戏名称列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void getBindGamesAccountList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    BindGameAccount gameAccount = Parser.getBindGameAccount(response);
                    if (gameAccount != null) {
                        if (gameAccount != null) {
                            vrHttpListener.onSuccess(gameAccount, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    BindGameAccount gameAccount = Parser.getBindGameAccount(cahce);

                    if (gameAccount != null) {
                        vrHttpListener.onSuccess(gameAccount, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 游戏名称列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void geBindBankcardList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    BankCardList bankCardList = Parser.getBindBankCardList(response);
                        if (bankCardList  != null) {
                            vrHttpListener.onSuccess(bankCardList, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    BankCardList bankCardList = Parser.getBindBankCardList(cahce);
                    if (bankCardList.card_list != null) {
                        vrHttpListener.onSuccess(bankCardList, false);
                    } else {
                        Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 挂单记录
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getCancelledRecordList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    CancelledRecorded cancelledRecordList = Parser.getCancelledRecordList(response);
                        if (cancelledRecordList != null) {
                            vrHttpListener.onSuccess(cancelledRecordList, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    CancelledRecorded cancelledRecordList = Parser.getCancelledRecordList(cahce);

                    if (cancelledRecordList != null) {
                        vrHttpListener.onSuccess(cancelledRecordList, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 挂单记录
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getInterconnectedList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    Interconnected interconnected = Parser.getInterconnectedList(response);

                        if (interconnected != null) {
                            vrHttpListener.onSuccess(interconnected, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    Interconnected interconnected = Parser.getInterconnectedList(cahce);
                    if (interconnected != null) {
                        vrHttpListener.onSuccess(interconnected, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 挂单记录
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getTradingRecordList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    UserTradingRecord tradingRecord = Parser.getTradingrecordList(response);
                        if (tradingRecord != null) {
                            vrHttpListener.onSuccess(tradingRecord, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    UserTradingRecord tradingRecord = Parser.getTradingrecordList(cahce);

                    if (tradingRecord.record_list != null) {
                        vrHttpListener.onSuccess(tradingRecord, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }



    /**
     * 微信支付
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */
    public static void getRechargeMoneyList(final Context context, final String url, final Map<String,String> mArgs,final VRHttpListener vrHttpListener){
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    RechargeMoney rechargeMoney = Parser.getRechargeMoneyList(response);
                    if (rechargeMoney.status.equals("0")) {
                        if(rechargeMoney != null){
                            vrHttpListener.onSuccess(rechargeMoney, false);
                        }else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }
            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    RechargeMoney rechargeMoney = Parser.getRechargeMoneyList(cahce);
                    ArrayList<RechargeMoneyDetails> details = rechargeMoney.pay_list;
                    if (details != null) {
                        vrHttpListener.onSuccess(details, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }
            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

    /**
     * 游戏名称列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void getWithdrawalRecoredsList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    WithdrawalRecords withdrawalList = Parser.getWithdrawalList(response);
                    if (withdrawalList.status.equals("0")) {

                        if (withdrawalList != null) {
                            vrHttpListener.onSuccess(withdrawalList, false);
                        } else {
                            Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                        }
                    } else {
//                        vrHttpListener.onError(userInfo.message);
                    }
                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    WithdrawalRecords withdrawalList = Parser.getWithdrawalList(cahce);
                    if (withdrawalList != null) {
                        vrHttpListener.onSuccess(withdrawalList, false);
                    } else {
                        vrHttpListener.onError(error.toString());
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 红包列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void getRedEnvelopeList(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    RedEnvelopeList redEnvelopeList = Parser.getRedEnvolopeList(response);
                    if (redEnvelopeList  != null) {
                        vrHttpListener.onSuccess(redEnvelopeList, false);
                    } else {
                        Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    RedEnvelopeList redEnvelopeList = Parser.getRedEnvolopeList(cahce);
                    if (redEnvelopeList != null) {
                        vrHttpListener.onSuccess(redEnvelopeList, false);
                    } else {
                        Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }


    /**
     * 红包列表
     *
     * @param context
     * @param url
     * @param mArgs
     * @param vrHttpListener
     */

    public static void getRedEnvelopeRecords(final Context context, final String url, final Map<String, String> mArgs, final VRHttpListener vrHttpListener) {
        asyncHttp.addRequest(new VRStringRequest(Request.Method.POST, url, mArgs, new Listener<String>() {
            @Override
            public void onSuccess(String response) {
                if (!TextUtils.isEmpty(response)) {
                    RedEnvelopeRecords redEnvelopeRecords = Parser.getRedEnvolopeRecords(response);
                    if (redEnvelopeRecords  != null) {
                        vrHttpListener.onSuccess(redEnvelopeRecords, false);
                    } else {
                        Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }

                } else {
                    vrHttpListener.onError("response 为空");
                }
            }

            @Override
            public void onError(NetroidError error) {
                super.onError(error);
                String cahce = asyncHttp.getStringCache(url);
                if (!TextUtils.isEmpty(cahce)) {
                    RedEnvelopeRecords redEnvelopeRecords =  Parser.getRedEnvolopeRecords(cahce);
                    if (redEnvelopeRecords != null) {
                        vrHttpListener.onSuccess(redEnvelopeRecords, false);
                    } else {
                        Toast.makeText(context, "数据为空", Toast.LENGTH_SHORT).show();
                    }
                } else {
                    vrHttpListener.onError(error.toString());
                }
            }

            @Override
            public void onFinish() {
                super.onFinish();
                vrHttpListener.onFinish();
            }
        }), TimeUnit.MINUTES, 10, true);
    }

}
